package controllers

import (
    "github.com/gin-gonic/gin"
    "hitme/go-api/logic/form"
    "hitme/go-api/logic/services"
    "hitme/go-api/modules/response"
    "hitme/go-api/modules/utils"
)

type idcardController struct {

}

var IdcardController idcardController

// GetList 获取列表
func (w *idcardController) GetList (c *gin.Context)  {
    // 获取参数并校验字段
    req := form.IdcardGetListReqForm{}
    if err := c.ShouldBind(&req); err != nil {
        utils.HandleValidatorError(c, err)
        return
    }

    res, err := services.IdcardService.GetList(c, req)

    if err != nil {
        response.Err(c, 400, 400, err.Error())
    } else {
        response.Success(c, 200, res)
    }
}

// GetListByCate 获取列表
func (w *idcardController) GetCateList (c *gin.Context)  {
    // 获取参数并校验字段
    req := form.IdcardGetCateListReqForm{}
    if err := c.ShouldBind(&req); err != nil {
        utils.HandleValidatorError(c, err)
        return
    }

    res, err := services.IdcardService.GetCateList(c, req)

    if err != nil {
        response.Err(c, 400, 400, err.Error())
    } else {
        response.Success(c, 200, res)
    }
}

// GetListByCate 获取列表
func (w *idcardController) GetListByCate (c *gin.Context)  {
    // 获取参数并校验字段
    req := form.IdcardGetListByCateReqForm{}
    if err := c.ShouldBind(&req); err != nil {
        utils.HandleValidatorError(c, err)
        return
    }

    res, err := services.IdcardService.GetListByCate(c, req)

    if err != nil {
        response.Err(c, 400, 400, err.Error())
    } else {
        response.Success(c, 200, res)
    }
}

// CutCheckPic 制作并检测证件照
func (w *idcardController) EnvMakeWm (c *gin.Context)  {
    // 获取参数并校验字段
    req := form.IdcardEnvMakeWmReqForm{}
    if err := c.ShouldBind(&req); err != nil {
        utils.HandleValidatorError(c, err)
        return
    }

    res, err := services.IdcardService.EnvMakeWm(c, req)

    if err != nil {
        response.Err(c, 400, 400, err.Error())
    } else {
        response.Success(c, 200, res)
    }
}

// CutChangeClothes 剪裁换正装
func (w *idcardController) ChangeClothWm (c *gin.Context)  {
    // 获取参数并校验字段
    req := form.IdcardCutChangeClothesReqForm{}
    if err := c.ShouldBind(&req); err != nil {
        utils.HandleValidatorError(c, err)
        return
    }

    res, err := services.IdcardService.ChangeClothWm(c, req)

    if err != nil {
        response.Err(c, 400, 400, err.Error())
    } else {
        response.Success(c, 200, res)
    }
}